/**
 * @Author yinyunqi
 * @date 2018年1月19日
 * @Content 
 */
package com.yongqi.controller.console;

import java.util.UUID;

import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.yongqi.model.Family;
import com.yongqi.model.console.Remind;
import com.yongqi.service.console.RemindService;

@Controller
@RequestMapping("/remind")
public class RemindController {
    @Autowired
    RemindService remindService;
    /**
     * 添加备忘
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping("/addRemind")
    public String addRemind(HttpServletRequest request) {
	String familyAccount = ((Family) SecurityUtils.getSubject().getPrincipal()).getFamilyaccount();
	Remind remind = new Remind();
	remind.setId(String.valueOf(UUID.randomUUID()));
	remind.setFamilyaccount(familyAccount);
	remind.setPlandate(request.getParameter("date"));
	remind.setMsg(request.getParameter("msg"));
	remindService.addRemind(remind);
	JSONObject object = new JSONObject();
	object.put("res", "success");
	return object.toJSONString();
    }
}

